//
//  XiuGaiXingBieViewController.m
//  XiangMu
//
//  Created by 康世标 on 15/8/26.
//  Copyright (c) 2015年 康世标. All rights reserved.
//

#import "XiuGaiXingBieViewController.h"
#import "Header.h"
@interface XiuGaiXingBieViewController ()

@end

@implementation XiuGaiXingBieViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"修改性别";
    self.view.backgroundColor = CL_efeff4;
    self.quRenBtn.backgroundColor = CL_00cc85;
    
    self.xuanZeArr = [[NSMutableArray alloc]initWithCapacity:0];
    
    [self.xuanZeArr addObject:self.nanBtn];
    [self.xuanZeArr addObject:self.nvBtn];
    
    
   
    
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"sex"] intValue] ==1)
    {
        self.nanBtn.selected = YES;
    }
    else{
        
        self.nvBtn.selected =YES;
    }
    
}
- (IBAction)XuanZe:(UIButton *)sender{
    
    for (UIButton * button in self.xuanZeArr)
    {
        
        button.selected = NO;
    }
    
    sender.selected = YES;
}
- (IBAction)quRen:(id)sender{
    
    int x;
    if (self.nanBtn.selected) {
        
    
        x =1;
    
    }
    else{
        
        x=2;
    }
    
    MBProgressHUD * HUD =[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    
    [QingQiuShuJu upDate:@(2) Param:[NSString stringWithFormat:@"%d",x] Block:^(NSDictionary *dic, BOOL isOK) {
        
        if (isOK) {
            
            NSUserDefaults * use =[NSUserDefaults standardUserDefaults];
            [use setObject:[[dic valueForKey:@"data"] valueForKey:@"sex"]forKey:@"sex"];
            
            HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]];
            
            // Set custom view mode
            HUD.mode = MBProgressHUDModeCustomView;
            
            
            HUD.labelText = @"修改成功";
            
            [HUD show:YES];
            [HUD hide:YES afterDelay:3];
            
        }
        else{
            
            HUD.labelText = @"请求失败";
            
            [HUD hide:YES afterDelay:2];
            HUD.removeFromSuperViewOnHide = YES;
            
        }
    }];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
